var gatt, time0, time1, settime0, settime1,kjtime,setkjtime, gntime,upl,gnews,tu;
var fastobj;

function myready() {
	$(document).keydown(function(event){ 
	      if(event.keyCode == 13){ 
		  if($(".sendtb:visible",parent.document).length==1){
			     if($(".sendtb .qr:visible",parent.document).length==1){
					 $(".sendtb .qr",parent.document).click();
				 }else if($(".sendtb:visible",parent.document).find("button:enabled").length>0){
				     $(".sendtb:visible",parent.document).find("button.close").click();
				 }
			 }else{
		var fje=false;
		$(".lists input:text").each(function(){
			var val= $(this).val();
		    if(!isNaN(val) & val%1==0 & val!=0 & val!=''){
			   fje=true;
			}
		});
		if(fje){
		    exe();
			return false;
		}
		  }
		  }
	});
	if(fudong==1){
		$(".fedu",parent.document).show();
	    $(".kedu",parent.document).hide();
		$(".dedu",parent.document).hide();
	}else{
	if(fast==0){
		$(".fedu",parent.document).hide();
	    $(".kedu",parent.document).hide();
		$(".dedu",parent.document).show();
	}else{
		$(".fedu",parent.document).hide();
	    $(".kedu",parent.document).show();
		$(".dedu",parent.document).hide();
	}
	}
	$("#kjurl",parent.document).attr('href',kjurl);
	
	$("div.control input:text").keyup(function() {
		$(this).val($(this).val().replace(/\D/g,''));
		var val = $(this).val()
		$("div.control input:text").val(val);
		$(".lists td.select").find("input:text").val(val);
		$.cookie('yusheje',val);
		$(".lists input:text").each(function(){
			if($(this).parent().hasClass("selected")){
				 $(this).val(val);
			}
		});
	}).keypress(function() {
		$(this).val($(this).val().replace(/\D/g,''));
		var val = $(this).val()
		$("div.control input:text").val(val);
		$(".lists td.select").find("input:text").val(val);
		$.cookie('yusheje',val);
		$(".lists input:text").each(function(){
			if($(this).parent().hasClass("selected")){
				 $(this).val(val);
			}
		});
	});
	$("div.control input:checkbox").click(function(){
		 if($(this).prop("checked")){
		    $.cookie('yushe',1);
		 }else{
		    $.cookie('yushe',0);	
		 }
	     $("div.control input:checkbox").prop("checked",$(this).prop("checked"));
	});	 

    if($.cookie('yushe')==1){
	    $("div.control input:checkbox").prop("checked",true);
		$("div.control input:text").val($.cookie('yusheje'));
	}

	$("input.jes").keyup(function() {
		$(this).val($(this).val().replace(/\D/g,''));
	}).keypress(function() {
		$(this).val($(this).val().replace(/\D/g,''));
	});
	
	$("div.control input:text:eq(0)").focus();
	$(".main a:eq(0)").addClass('click');
	$("a.ab:eq(1)").addClass('on');
	
	
	
	if ($(".time0").html() != undefined) {
		time0 = Number($(".time0").html());
		if (Math.abs(time0) <= 2) {}
		if (time0 < 0) time0 = 0 - time0;
		time0x();
		gntime = setTimeout(getnowtime, 10000)
	}
	if ($(".time1").html() != undefined) {
		time1 = Number($(".time1").html());
		if (Math.abs(time1) <= 2) {}
		if (time1 < 0) time1 = 0 - time1;
		time1x();
	}

	if ($(".kjtime").html() != undefined & 1==2) {
		kjtime = Number($(".kjtime").html());
		if (Math.abs(kjtime) <= 2) {}
		if (kjtime < 0) kjtime = 0 - kjtime;
		//kjtimex();
	}

	
	upl = setTimeout(updatel, 1000);


	lib();
	setTimeout(getlast15, 2000);
	gnews = setTimeout(getnews, 3000);
	setTimeout(onefunc, 1000);
	//xreload();
}


function onefunc() {

    $(".sendtb .close",parent.document).click(function(){
	    $(".sendtb",parent.document).hide();
		$(".ui-front",parent.document).hide();
	});
$(".news button.close",parent.document).click(function(){$(".news",parent.document).hide();});
	$(".more",parent.document).click(function(){
	$.ajax({
		type: 'POST',
		cache: false,
		url: 'userinfo.php',
		data: 'xtype=getnewsall',
		success: function(m) {
			$(".news",parent.document).show();
			 $(".news tbody",parent.document).html(m);
		}
	})
	})

	$(".main a").click(function() {
		$(".main a").removeClass('click');
		$(this).addClass('click');
		if (fenlei == 100) {
			var bname=$(".main a.click").html();
			if (bname == '特碼') {
				$(".panstatus").show();
				$(".otherstatus").hide()
			} else {
				$(".panstatus").hide();
				$(".otherstatus").show()
			}
			if (bname == '特碼' | bname == '正特' | bname == '正碼') {
				$("a.ab").show();
			    $("a.ab:eq(1)").html(bname+'A');
				$("a.ab:eq(0)").html(bname+'B');	

				if(fastinput==1){$(".fasttext").show();}
			}else{
				$(".fasttext").hide();
		        $("a.ab").hide();
			}
		}else{
		   $("a.ab").hide();
		}
		$(".longr").show();
		$(".baodiv").hide();
		$(".baodiv").html('');
		$("#con").show();
		$(".con1").empty();
		$(".con1").hide();
		$("#long").hide();
		$(".info").show();
		lib();
		return false
	});
	$(".game").change(function() {
		var gid = $(this).val();
		$.ajax({
			type: 'POST',
			cache: false,
			url: 'makelib.php',
			data: 'xtype=setgame&gid=' + gid,
			success: function(m) {
				if (Number(m) == 1) {
					window.location.reload();
				}
			}
		})
	});


	$(".cancel").click(function() {
		var zje =$(".zje").val();
		$("input:text").val('');
		$(".zje").val(zje);
		$(".selected").removeClass('selected');
		$(".selected2").removeClass('selected2');
		$(".ggpeilv").html('');
		$(".textnr").val('');
		
	});

   $("a.ab").click(function() {
		$("a.ab").removeClass('on');
		$(this).addClass('on');
		lib();
	});
	

	
	$(".reload").click(function() {
		window.location.reload();
		return false
	});
	$(".exe").click(function() {
		exe();
		return false
	});
	$(".fastg").click(function() {
		if ($(this).val() == "勾选") {
			$(".make input:text").hide();
			$(".make input:checkbox").show();
			$(".fastg").val('快速')
		} else {
			$(".make input:text").show();
			$(".make input:checkbox").hide();
			$(".fastg").val('勾选')
		}
	});
	$(".fastgje").blur(function() {
		$(".fastgje").val($(this).val());
		$(".make input.byellow").val($(this).val());
	});
	$(".fastgsend").click(function() {
		var je = $(".fastgje").val();
		if (isNaN(Number(je)) | Number(je) % 1 != 0 | Number(je) == 0) {
			alert("请输入正确的金额！");
			return false
		}
		if ($(".fastg").val() == '勾选') {
			$(".make input.byellow").val(je)
		} else {
			$(".make input:checkbox").each(function() {
				if ($(this).prop("checked") == true) {
					$(this).parent().find("input:text").val(je)
				}
			});
			$(".exe").click()
		}
	});


}

function getnews() {
	clearTimeout(gnews);
	$.ajax({
		type: 'POST',
		url: 'userinfo.php',
		dataType: 'json',
		data: 'xtype=getnews',
		cache: false,
		success: function(m) {
			var mlength = m.length;
			if (mlength == 0) return false;
			var str = '';
			for (i = 0; i < mlength; i++) {
				str += '' + m[i]['content'] + '<label>[' + m[i]['time'] + ']</label>&nbsp;'
			}
			$("#notices",parent.document).html(str);
			if (m[0]['mc'] != '' & m[0]['mc'] != undefined & m[0]['mc'] != 'undefined') {
				alert(m[0]['mc']);
			}
			m = null;
			str = null
		}
	});
	gnews = setTimeout(getnews, 30000);
}
function updatel() {
	clearTimeout(upl);
    var m1 = $("#result_balls",parent.document).find("span:eq(0)").find("b").html();
	var qs = $("#result_info",parent.document).attr('v');
	var t = $(".main a.click").attr('t');
	if(fenlei==100 | fenlei==151) t=0;
	var obj = $("#result_info",parent.document);
	var objb = $("#result_balls",parent.document);
	//alert("xtype=upl&qs=" + qs + "&m1=" + m1 + "&tu=" + t)
	if(m1==undefined) m1='';
	$.ajax({
		type: 'POST',
		url: 'make.php',
		dataType: 'json',
		cache: false,
		data: "xtype=upl&qs=" + qs + "&m1=" + m1 + "&tu=" + t,
		success: function(m) {
		   //$("#test").html(m);return;
		   //alert(m[0]);
		    getusermoney();	
			if (m[0] != 'A') {
				obj.attr('v',m[5]);
				obj.find("div:eq(0)").html(m[6]);
				obj.find("div:eq(1)").html(m[5]+"期开奖");
				var ml = m[4].length;
				var str="";
				var sum=0;
				
				if(fenlei==163){
				   qiunames= ["百","十","个"];
				}
				if(fenlei==101){
				   qiunames= ["万","千","百","十","个"];
				}
				for(i=0;i<ml;i++){
				   if(fenlei==107) 	if(m[4][i]!='' ){m[4][i] = Number(m[4][i]);}
				   if(fenlei==100 & i==ml-1) 	if(m[4][i]!=''  & m[4][i]!=null ){str += "<span class='plus'>+</span>";}
				   if(fenlei==163){
				     if(m[4][i]!='' ){
						 str += "<span><b class='b"+m[4][i]+"'>"+m[4][i]+"</b><i style='margin-left:-10px;'>"+qiunames[i]+"</i>";
						 if(i==ml-1) str += "<i style='margin:-35px 0px 0px 40px'>=</i>";
						 else str += "<i style='margin:-35px 0px 0px 40px'>+</i>";
						 str += "</span>";
						 sum += Number(m[4][i]);
					 }
				   }else{
					 if(m[4][i]!='' & m[4][i]!=null){
						 if(fenlei==101){
						   str += "<span><b class='b"+m[4][i]+"'>"+m[4][i]+"</b><i>"+qiunames[i]+"</i></span>";
						 }else{
						   str += "<span><b class='b"+m[4][i]+"'>"+m[4][i]+"</b></span>";
						 }
					 }
				   }
				}
				if(fenlei==163){
					if(str!='') str += "<span><b class='bg b_"+sum+"'>"+sum+"</b><i>和</i></span>";
				}
				   objb.html(str);
				   objb.attr("class","T"+fenlei);
				  
				   if(fenlei==100) return ;
				            
				   $("#changlong").html(m[1]);
				   $("#changlong").hide('fast');
				   $("#changlong").show('fast');
				   if(fenlei==151) {
					   $("#changlong").addClass("table_ball");
					   $("#changlong").attr("id","historyResult")
				   }
				    $(".longr td").hover(function(){$(this).addClass('hover');$(this).parent().find("th").addClass('hover')},function(){$(this).removeClass('hover');$(this).parent().find("th").removeClass('hover')});
					$(".longr th").hover(function(){$(this).addClass('hover');$(this).parent().find("td").addClass('hover')},function(){$(this).removeClass('hover');$(this).parent().find("td").removeClass('hover')});
				   $("input[name='longfs']").change(function(){
				      if($(this).val()==1){
					      $(".buz").hide();
						  $(".zz").show();
					  }else{
					      $(".buz").show();
						  $(".zz").hide();
					  }
				   });
				    $("input[name='longfs']:eq(1)").change();
				   if (m[3] == 1) {
				 	  bofang("kaijiang");
				   }
				 
			   	   if (t>0) {
					 tu = m[2];
					 tuset();
				   }
				  libpl(1);
				  
				}
				
			
		}
	});
	upl =  setTimeout(updatel, 5000);
}

function dwsendtb(){
	  if($(".sendtb").is(':visible')){   
       var top = $(window).scrollTop();
	   if(top<=80) top=80;
       var left= 2;
       $(".sendtb").css({ left:left + "px", top: top + "px" });
	  }
}

function longsrc() {
	if (document.frames) {
		document.all["long"].src = "long.php?xtype=show"
	} else {
		document.getElementById("long").contentWindow.location.href = "long.php?xtype=show"
	}
}

function getm(val) {
	return sma[val]
}

function setdate(val) {
	var start = $("#start");
	var end = $("#end");
	switch (val) {
	case 1:
		start.val(sdate[10]);
		end.val(sdate[10]);
		break;
	case 2:
		start.val(sdate[0]);
		end.val(sdate[0]);
		break;
	case 3:
		start.val(sdate[5]);
		end.val(sdate[6]);
		break;
	case 4:
		start.val(sdate[7]);
		end.val(sdate[8]);
		break;
	case 5:
		start.val(sdate[1]);
		end.val(sdate[2]);
		break;
	case 6:
		start.val(sdate[3]);
		end.val(sdate[4]);
		break
	}
}

function getusermoney() {

	$.ajax({
		type: 'POST',
		url: 'userinfo.php',
		dataType: "json",
		cache: false,
		data: 'xtype=getusermoney',
		success: function(m) {
            var obj = $(".accounts",parent.document);
			obj.find(".maxmoney").html(m[0]);
			obj.find(".money").html(m[1]);
			obj.find(".moneyuse").html(m[2]);
			obj.find(".kmaxmoney").html(m[3]);
			obj.find(".kmoney").html(m[4]);
			obj.find(".kmoneyuse").html(m[5]);
			obj.find(".fmaxmoney").html(m[3]);
			obj.find(".fmoney").html(m[4]);
			obj.find(".fmoneyuse").html(m[5]);
			$(".thisqishu").html(m[6]);
			$(".synow").html(m[7])
		}
	})
}

function getlast15() {
	$.ajax({
		type: 'POST',
		url: 'makelib.php',
		data: 'xtype=getlast15',
		dataType: 'json',
		cache: false,
		success: function(m) {
			var ml = m.length;
			var str = '';
			var name = '';
			var peilv='';
			var obj = $(".last15",parent.document);			
			for (i = 0; i < ml; i++) {
				peilv = m[i]['peilv1'];
				if (Number(m[i]['peilv2']) >= 10) {
					peilv += "/" + m[i]['peilv2']
				}
				str += "<li><p>注单号：<span class='bid'>"+m[i]['tid']+"#</span></p><p class='contents'><span class='text'>"+m[i]['name']+"</span>@<span class='odds'>"+peilv+"</span></p><p>金额：￥"+m[i]['je']+"&nbsp;&nbsp;时间:"+m[i]['time']+"</p></li>";
			}
			obj.html(str);
		}
	})
}

function scclick() {
	$(".smenu td:eq(0)").find("input").click(function() {
		$(".smenu td:eq(0) input").removeClass('click');
		$(this).addClass('click');
		lib();
		return false
	})
}

function transk3(n) {
	var v;
	if (isNaN(n)) v = n;
	else {
		if (n > 100) {
			v = "<img src='../imgn/4_" + (n % 10) + ".gif' /><img src='../imgn/4_" + (n % 10) + ".gif' /><img src='../imgn/4_" + (n % 10) + ".gif' />"
		} else if (n > 10) {
			v = "<img src='../imgn/4_" + n.substr(0, 1) + ".gif' /><img src='../imgn/4_" + (n % 10) + ".gif' />"
		} else {
			v = "<img src='../imgn/4_" + n + ".gif' />"
		}
	}
	return v
}

function checkclose() {
	var bid = Number($(".main a.click").attr("bid"));
	var name = $(".main a.click").html();
	$.ajax({
		type: 'POST',
		url: 'make.php',
		dataType: 'json',
		cache: false,
		data: 'xtype=getpan',
		success: function(m) {
			if (Number(m['panstatus']) == 0) {
				$("f").attr('disabled', true)
			} else {
				$(".exe").attr('disabled', false)
			}
		}
	})
}

function getatt() {
	var abcd = $("#abcd", parent.document).val();;
	var ab = $("a.ab.on").attr('v');
    clearTimeout(gatt);
	
	$.ajax({
		type: 'POST',
		url: 'makelib.php',
		data: 'xtype=getatt&abcd=' + abcd + "&ab=" + ab + "&gid=" + ngid,
		dataType: 'json',
		cache: false,
		success: function(m) {
			var ml = m.length;
			if (ml >= 1) {
				bofang("dd");	
			}
			var i = 0;
			for (; i < ml; i++) {
				$(".lists td.p" + m[i]['pid']).find("label.peilv1").html(m[i]['peilv1']);
				$(".lists td.p" + m[i]['pid']).addClass('blue');
			}
			if (i != 0) {
				setTimeout(function() {
					$(".lists .blue").removeClass('blue')
				}, 5000)
			}
			gatt = setTimeout(getatt, 3000)
		}
	})
}

function bofang() {
	if (document.frames) {
		document.all["sfrm"].src = globalpath + "js/alarm.html"
	} else {
		document.getElementById("sfrm").contentWindow.location.href = globalpath + "js/alarm.html"
	}
}
var stra = "<table class='wd100 makehead'><tr><Th class=f>NO</th><th class=s>赔率</th><Th class=t>金额</th></tr></table>";
var strb = "<tr><Th>项目</th><th>赔率</th><th>号码</th><Th>金额</th></tr>";
var strc = "<tr><Th>项目</th><th class=h40>赔率</th><Th>选择</th></tr>";

function addfunc() {
	$(".lists input:text").attr("maxlength", 7);
	$(".lists input:text").keyup(function(){$(this).val($(this).val().replace(/\D/g,''));}).keypress(function(){$(this).val($(this).val().replace(/\D/g,''));});
	
			$('.lists td').hover(function() {
				var pid = $(this).attr('pid');
				$(".lists td.p" + pid).addClass('hover');
				$(".lists td.i" + pid).addClass('hover');
				$(".lists td.img" + pid).addClass('hover');
				$(".lists th.m" + pid).addClass('hover');
			}, function() {
				var pid = $(this).attr('pid');
				$(".lists td.p" + pid).removeClass('hover');
				$(".lists td.i" + pid).removeClass('hover');
				$(".lists td.img" + pid).removeClass('hover');
				$(".lists th.m" + pid).removeClass('hover');
			});
		

	
	
	$(".lists td.p").click(function() {
		var pid = $(this).attr('pid');
		var je = $("div.control input:text").val();
		if($(this).hasClass('selected')){
		    $(".lists td.p"+pid).removeClass("selected");
			$(".lists td.i"+pid).removeClass("selected");
			$(".lists td.img"+pid).removeClass("selected");		
			$(".lists th.m"+pid).removeClass("selected");
		}else{
		    $(".lists td.p"+pid).addClass("selected");
			$(".lists td.i"+pid).addClass("selected");
			$(".lists th.m"+pid).addClass("selected");
			$(".lists td.img"+pid).addClass("selected");
			if(!$(".lists td.i"+pid).find("input:text").prop("disabled")){		 
                $(".lists td.i"+pid).find("input:text").val(je);
			}
		}
	});
	$(".lists td.i").click(function() {
		var pid = $(this).attr('pid');
		var je = $("div.control input:text").val();
		if($(this).hasClass('selected')){
		    $(".lists td.p"+pid).removeClass("selected");
			$(".lists td.i"+pid).removeClass("selected");
			$(".lists td.img"+pid).removeClass("selected");				
			$(".lists th.m"+pid).removeClass("selected");
		}else{
		    $(".lists td.p"+pid).addClass("selected");
			$(".lists td.i"+pid).addClass("selected");
			$(".lists th.m"+pid).addClass("selected");
			$(".lists td.img"+pid).addClass("selected");	 
			if(!$(".lists td.i"+pid).find("input:text").prop("disabled")){		 
                $(".lists td.i"+pid).find("input:text").val(je);
			}
		}
	});
	$(".lists th.m").click(function() {
		var pid = $(this).attr('pid');
		var je = $("div.control input:text").val();
		if($(this).hasClass('selected')){
		    $(".lists td.p"+pid).removeClass("selected");
			$(".lists td.i"+pid).removeClass("selected");
			$(".lists td.img"+pid).removeClass("selected");				
			$(".lists th.m"+pid).removeClass("selected");
		}else{
		    $(".lists td.p"+pid).addClass("selected");
			$(".lists td.i"+pid).addClass("selected");
			$(".lists th.m"+pid).addClass("selected");
			$(".lists th.img"+pid).addClass("selected");		 
			if(!$(".lists td.i"+pid).find("input:text").prop("disabled")){		 
                $(".lists td.i"+pid).find("input:text").val(je);
			}
		}
	});
	
	$(".lists input:text").focus(function() {
		if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105))){
           event.returnValue=false;
		 }
		
	});

	clearTimeout(gatt);
	gatt = setTimeout(getatt, 3000)
}

function getnowtime() {
	clearTimeout(gntime);
	$.ajax({
		type: 'POST',
		url: 'time.php',
		data: 'xtype=getopen',
		cache: false,
		success: function(m) {
			m = m.split('|');
			if(Number(m[6])==0 | m[6]==undefined){
			   top.window.location.href= top.window.location.href;
			   return false;
			}
			if (fenlei == 100) {
				if (Number(m[2]) != Number($(".thisqishu").html()) | Number(m[3]) != Number($(".panstatus").attr('s')) | Number(m[4]) != Number($(".otherstatus").attr('s'))) {
					$(".panstatus").attr('s', m[3]);
					$(".otherstatus").attr('s', m[4]);
					if (Number(m[3]) == 0) {
						$(".panstatus").html($(".panstatus").html().replace("关", "开"))
					} else {
						$(".panstatus").html($(".panstatus").html().replace("开", "关"))
					}
					if (Number(m[4]) == 0) {
						$(".otherstatus").html($(".otherstatus").html().replace("关", "开"))
					} else {
						$(".otherstatus").html($(".otherstatus").html().replace("开", "关"))
					}
					$(".thisqishu").html( m[2]);
					if(Number(m[5])<2100 | Number(m[5])>2128){
					    lib();
					}
					getusermoney();
					getlast15();
				}
				clearTimeout(settime1);
				time1 = Number(m[1]);
				time1x()
			} else {
				//alert(m[2]+","+$(".status").attr('qs')+','+m[3]+$(".panstatus").attr('s'))
				if (Number(m[2]) != Number($(".thisqishu").html()) | Number(m[3]) != Number($(".panstatus").attr('s'))) {
					$(".panstatus").attr('s', m[3]);

					if (Number(m[3]) == 0) {
						$(".panstatus").html($(".panstatus").html().replace("关", "开"))
					} else {
						$(".panstatus").html($(".panstatus").html().replace("开", "关"))
					}
					$(".thisqishu").html( m[2]);
					lib();
					getusermoney();
					getlast15();
				}
			}
			clearTimeout(settime0);
			time0 = Number(m[0]);
			time0x()
		}
	});
	gntime = setTimeout(getnowtime, 5000)
}

function time0x() {
	time0--;
	var str = '';
	var d = 0,
		h = 0,
		m = 0,
		s = 0;
	d = Math.floor(time0 / (60 * 60 * 24));
	h = Math.floor((time0 - d * 60 * 60 * 24) / (60 * 60));
	m = Math.floor((time0 - d * 60 * 60 * 24 - h * 60 * 60) / 60);
	s = time0 - d * 60 * 60 * 24 - h * 60 * 60 - m * 60;
	if (d > 0) str += "<label>" + d + "</label>天";
	if (h > 0) str += "<label>" + h + "</label>时";
	if (m > 0) str += "<label>" + m + "</label>分";
	str += "<label>" + s + "</label>秒";
	if (time0 > 0) {
		$(".time0").html(str)
	} else {
		$(".time0").html("<label>0</label>秒")
	}
	if (time0 <= 0) {
		getnowtime();
		return true;
	}
	settime0 = setTimeout(time0x, 1000)
}

function time1x() {
	time1--;
	var str = '';
	var d = 0,
		h = 0,
		m = 0,
		s = 0;
	d = Math.floor(time1 / (60 * 60 * 24));
	h = Math.floor((time1 - d * 60 * 60 * 24) / (60 * 60));
	m = Math.floor((time1 - d * 60 * 60 * 24 - h * 60 * 60) / 60);
	s = time1 - d * 60 * 60 * 24 - h * 60 * 60 - m * 60;
	if (d > 0) str += "<label>" + d + "</label>天";
	if (h > 0) str += "<label>" + h + "</label>时";
	if (m > 0) str += "<label>" + m + "</label>分";
	str += "<label>" + s + "</label>秒";
	if (time1 > 0) {
		$(".time1").html(str)
	} else {
		$(".time1").html("<label>0</label>秒")
	}
	if (time1 <= 0) {
		getnowtime();
		return true;
	}
	settime1 = setTimeout(time1x, 1000)
}

function kjtimex() {
	kjtime--;
	var str = '';
	var d = 0,
		h = 0,
		m = 0,
		s = 0;
	d = Math.floor(kjtime / (60 * 60 * 24));
	h = Math.floor((kjtime - d * 60 * 60 * 24) / (60 * 60));
	m = Math.floor((kjtime - d * 60 * 60 * 24 - h * 60 * 60) / 60);
	s = kjtime - d * 60 * 60 * 24 - h * 60 * 60 - m * 60;
	if (d > 0) str += "<label>" + d + "</label>天";
	if (h > 0) str += "<label>" + h + "</label>时";
	if (m > 0) str += "<label>" + m + "</label>分";
	str += "<label>" + s + "</label>秒";
	if (kjtime > 0) {
		$(".kjtime").html(str)
	} else {
		$(".kjtime").html("<label>0</label>秒")
	}
	if (kjtime <= 0) {
		getnowtime();
		return true;
	}
	setkjtime = setTimeout(kjtimex, 1000)
}


function getlogin() {
	$.ajax({
		type: 'POST',
		url: 'getlogin.php',
		data: 'xtype=getlogin',
		cache: false,
		success: function(m) {
			if (Number(m) == 1) {
				window.location.href = window.location.href
			} else {
				setTimeout(getlogin, 10000)
			}
		}
	})
}

function page(rcount, psize, func) {
	var pcount, pstr = '';
	pcount = rcount % psize == 0 ? rcount / psize : (rcount - rcount % psize) / psize + 1;
	for (i = 1; i <= pcount; i++) {
		pstr += "<a href='javascript:void(0)' p='" + i + "' class='page";
		if (i == tpage) pstr += " red";
		pstr += "' >" + i + "</a>"
	}
	$("#page").html(pstr);
	$("#page a").click(function() {
		tpage = Number($(this).attr('p'));
		eval(func)();
		return false
	})
}

var psize = 100;
var tpage = 1;





function getma(val) {
	var tmp = new Array();
	for (x = 0; x < mal; x++) {
		if (ma[x]['name'] == val) {
			tmp = ma[x]['ma'];
			break
		}
	}
	var xstr = '';
	for (x = 0; x < tmp.length; x++) {
		var j = tmp[x];
		if (j <= 9) j = '0' + j;
		xstr += "<img src='" + globalpath + "imgs/" + j + ".gif' />"
	}
	return xstr
}

function getma2(val) {
	var tmp = new Array();
	for (x = 0; x < mal; x++) {
		if (ma[x]['name'] == val) {
			tmp = ma[x]['ma'];
			break
		}
	}
	var xstr = '';
	for (x = 0; x < tmp.length; x++) {
		var j = tmp[x];
		if (x != 0) xstr += ',';
		xstr += j
	}
	return xstr
}

function getmas(val) {
	var tmp = new Array();
	for (x = 0; x < mal; x++) {
		if (ma[x]['name'] == val) {
			tmp = ma[x]['ma'];
			break
		}
	}
	var xstr = '';
	for (x = 0; x < tmp.length; x++) {
		var j = tmp[x];
		if (j <= 9) j = '0' + j;
		xstr += "<label style='color:" + color(j) + "'>" + j + "</label>"
	}
	return xstr
}



function xreload() {
	if (document.frames) {
		document.all["check"].src = 'check.php'
	} else {
		document.getElementById("check").contentWindow.location.href = 'check.php'
	}
	setTimeout(xreload, 55000)
}

